package io.renren.modules.vastFinance.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.UUID;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.vastFinance.entity.InformationEntity;
import io.renren.modules.vastFinance.service.InformationService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

import javax.annotation.Resource;


/**
 * 信息表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-05-18 19:54:59
 */
@RestController
@RequestMapping("vastFinance/information")
public class InformationController {
    @Autowired
    private InformationService informationService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("vastFinance:information:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = informationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{infoId}")
    @RequiresPermissions("vastFinance:information:info")
    public R info(@PathVariable("infoId") Integer infoId){
		InformationEntity information = informationService.getById(infoId);

        return R.ok().put("information", information);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("vastFinance:information:save")
    public R save(@RequestBody InformationEntity information){
		informationService.save(information);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("vastFinance:information:update")
    public R update(@RequestBody InformationEntity information){
		informationService.updateById(information);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("vastFinance:information:delete")
    public R delete(@RequestBody Integer[] infoIds){
		informationService.removeByIds(Arrays.asList(infoIds));

        return R.ok();
    }

    /**
     * 审核更改状态
     * @param infoId
     * @param infoStatus
     */
    @RequestMapping("examination")
    public void examination(@RequestParam("infoId") Integer infoId,@RequestParam("infoStatus") Integer infoStatus){
        informationService.examination(infoId,infoStatus);
    }

}
